<template>
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button
          style="margin-left: 15px"
          type="primary"
          @click="handleSearchList()"
          size="small"
          >查询搜索</el-button
        >
        <el-button
          style="margin-left: 15px"
          @click="handleResetSearch()"
          size="small"
          >重置</el-button
        >
      </div>
      <div style="margin-top: 15px">
        <el-form
          :inline="true"
          :model="listQuery"
          size="small"
          label-width="140px"
        >
          <el-form-item label="商家ID：">
            <el-input
              v-model="listQuery.masterID"
              class="input-width"
              placeholder="根据商家ID进行查询"
            ></el-input>
          </el-form-item>
          <el-form-item label="收货人电话号码：">
            <el-input
              v-model="listQuery.mobile"
              class="input-width"
              placeholder="请输入收货人的电话号码"
            ></el-input>
          </el-form-item>
          <el-form-item label="订单状态：">
            <el-select
              v-model="listQuery.status"
              class="input-width"
              placeholder="全部"
              clearable
            >
              <el-option
                v-for="item in statusOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="支付类型：">
            <el-select
              v-model="listQuery.payType"
              class="input-width"
              placeholder="全部"
              clearable
            >
              <el-option
                v-for="item in payTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="支付时间：">
            <el-date-picker
              v-model="listQuery.time"
              type="daterange"
              align="right"
              value-format="yyyy-MM-dd"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <el-card class="filter-container" shadow="never">
      <div>
        <span>数据导出</span>
        <el-button
          style="margin-left: 30px"
          type="primary"
          @click="tableToExcel2('Order/listDownload')"
          size="small"
          >列表数据导出</el-button
        >
        <el-button
          style="margin-left: 30px"
          type="primary"
          @click="tableToExcel2('Order/totalDetail')"
          size="small"
          >列表详情数据导出</el-button
        >
        <el-button
          style="margin-left: 30px"
          type="primary"
          @click="tableToExcel2('Order/detailDownload')"
          size="small"
          >商家数据导出</el-button
        >
        <el-button
          style="margin-left: 30px"
          type="primary"
          @click="alldelivery()"
          size="small"
          >订单导入发货</el-button
        >
      </div>
    </el-card>
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span
        ><span style="font-size: 16px; font-weight: 600">订单</span
        >数据列表</span
      >
      <!-- <el-button style="margin-left:30px" type="primary" @click="tableToExcel" size="small">单个数据导出</el-button> -->

      <!-- <el-button style="margin-left:30px" type="primary" @click="sendSMS()" size="small">批量发送短信</el-button>
      <el-button type="primary" size="small" style="margin-left:20px" @click="delivery()">一键发货</el-button> -->
      <span style="margin-left: 30px">{{
        "支付金额总计：" + amount + "元"
      }}</span>
      <span style="margin-left: 30px">{{
        "商品金额总计：" + money + "元"
      }}</span>
    </el-card>
    <div class="table-container">
      <el-table
        ref="orderTable"
        :data="list"
        style="width: 100%"
        @select-all="handleSelectionChange1"
        @select="handleSelectionChange"
        v-loading="listLoading"
      >
        <!-- <el-table-column
          type="selection"
          width="60"
          align="center"
        ></el-table-column> -->
        <el-table-column
          prop="orderID"
          label="订单ID"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="tradeNo"
          label="订单号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="orderName"
          label="订单名称"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="userID"
          label="用户id"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="nickname"
          label="用户昵称"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="mobile"
          label="收货人手机号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="masterID"
          label="商家id"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="masterName"
          label="商家名称"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="amount"
          label="支付金额"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="payTypeText"
          label="支付方式"
          align="center"
        ></el-table-column>
        <el-table-column prop="statusText" label="订单状态" align="center">
          <template slot-scope="scope">
            <span :style="scope.row.status == 1 ? 'color:red' : ''">{{
              scope.row.statusText
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="payTime" label="支付时间" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.payTime == 0 ? "" : scope.row.payTime }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="finishTime" label="提货时间" align="center">
          <template slot-scope="scope">
            <span>{{
              scope.row.finishTime == 0 ? "" : scope.row.finishTime
            }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="250" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              @click="handleViewOrder(scope.$index, scope.row)"
              >查 看 订 单</el-button
            >
            <el-button
              size="mini"
              v-if="scope.row.status == 1"
              @click="xdelivery(scope.row)"
              >发货</el-button
            >
            <!-- <el-button
              size="mini"
              v-if="scope.row.status==2"
              @click="overbtn(scope.$index, scope.row)"
            >完 成 订 单</el-button>
            <el-button
              size="mini"
              v-if="scope.row.status==2"
              style="margin-top:10px;"
              @click="sendSMS(scope.row.orderID)"
              :type="scope.row.smsSum>0?'':'danger'"
            >发 送 短 信</el-button>
            <el-button
              size="mini"
              style="margin-top:10px;"
              v-if="scope.row.status==2||scope.row.status==3"
              @click="print(scope.row.orderID)"
              :type="scope.row.printSum==0?'primary':''"
            >选择打印小票</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <div
        class="margin-top-15"
        style="text-align: center; padding: 0 50px 50px 50px"
      >
        <Page
          :total="tableShow.listCount"
          :current="tableShow.currentPage"
          :page-size="tableShow.pageSize"
          @on-change="changePage"
          @on-page-size-change="changeSize"
          show-elevator
          show-sizer
          show-total
        ></Page>
      </div>
    </div>

    <!-- 退款 -->
    <el-dialog
      title="退货退款处理"
      :append-to-body="true"
      top="200px"
      :visible.sync="refundVisible"
      width="30%"
    >
      <el-form :model="refundList" ref="receiverInfoForm" label-width="90px">
        <el-form-item label="退款金额：">
          <el-input
            v-model="refundList.money"
            placeholder="不填写则退还全部金额"
            style="width: 200px"
          ></el-input
          >元
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="refundVisible = false">返 回</el-button>
        <el-button type="primary" @click="RefundSubmit(6)">拒 绝</el-button>
        <el-button @click="RefundSubmit(5)">同 意</el-button>
      </span>
    </el-dialog>
    <!-- 打印机 -->
    <el-dialog
      title="打印机选择"
      :append-to-body="true"
      top="200px"
      :visible.sync="printerVisible"
      width="30%"
    >
      <div style="display: flex; justify-content: center">
        <el-button
          type="primary"
          style="margin-right: 40px"
          @click="printing(1)"
          >打印机一号</el-button
        >
        <el-button type="primary" @click="printing(2)">打印机二号</el-button>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button @click="printerVisible = false">返 回</el-button>
      </span>
    </el-dialog>
    <!-- 发货 -->
    <xdelivery
      :deliveryVisible="deliveryVisible"
      :orderID="deliveryData"
      :all="allxx"
      @hidden="hidden"
    ></xdelivery>
  </div>
</template>
<script>
import axios from "axios";
import config from "../../../build/config";
import xdelivery from "./common/delivery_goods";
export default {
  components: {
    xdelivery,
  },
  data() {
    return {
      visible: false,
      money: "",
      allxx: false,
      /**
       * 搜索
       */
      listQuery: {},
      payTypeOptions: [
        {
          label: "现金支付",
          value: 1,
        },
        {
          label: "组合支付",
          value: 2,
        },
      ],
      statusOptions: [
        {
          label: "待付款",
          value: -1,
        },
        {
          label: "支付失败",
          value: -3,
        },
        {
          label: "待发货",
          value: 1,
        },
        {
          label: "待提货",
          value: 2,
        },
        {
          label: "已完成",
          value: 3,
        },
        {
          label: "申请退款",
          value: 4,
        },
        {
          label: "已取消",
          value: 5,
        },
      ],
      orderTypeOptions: [
        {
          label: "正常订单",
          value: 0,
        },
        {
          label: "秒杀订单",
          value: 1,
        },
      ],
      sourceTypeOptions: [
        {
          label: "PC订单",
          value: 0,
        },
        {
          label: "APP订单",
          value: 1,
        },
      ],
      /**
       * 表格
       */
      list: [],
      listLoading: false,
      tableShow: {
        currentPage: 1,
        pageSize: 10,
        listCount: 0,
      },
      tableAreaData: [],
      amount: "",
      // 发货
      deliveryVisible: false,
      deliveryData: {},
      // 查快递
      logisticsVisible: false,
      logisticsTradeNo: {},
      // 退款
      refundVisible: false,
      refundList: {},
      multipleSelection: [],
      tableMasterData: [],
      printerVisible: false,
      printerOrder: "",
    };
  },
  created() {
    this.tableShow.currentPage = parseInt(sessionStorage.getItem("page")) || 1;
    this.tableShow.pageSize = parseInt(sessionStorage.getItem("size")) || 10;
    if (sessionStorage.getItem("search")) {
      this.listQuery = JSON.parse(sessionStorage.getItem("search")) || "";
    }
    this.getList(this.multipleSelection);
  },
  methods: {
    alldelivery() {
      this.deliveryVisible = true;
      this.allxx = true;
    },
    xdelivery(row) {
      this.deliveryVisible = true;
      this.allxx = false;
      this.deliveryData = row.orderID;
    },
    objectToQuery() {
      let obj = arguments[0];
      let prefix = arguments[1];
      if (typeof obj !== "object") return "";
      const attrs = Object.keys(obj);
      return attrs.reduce((query, attr, index) => {
        // 判断是否是第一层第一个循环
        if (index === 0 && !prefix) query += "?";
        if (typeof obj[attr] === "object") {
          const subPrefix = prefix ? `${prefix}[${attr}]` : attr;
          query += this.objectToQuery(obj[attr], subPrefix);
        } else {
          if (prefix) {
            query += `${prefix}[${attr}]=${obj[attr]}`;
          } else {
            query += `${attr}=${obj[attr]}`;
          }
        }
        // 判断是否是第一层最后一个循环
        if (index !== attrs.length - 1) query += "&";
        return query;
      }, "");
    },
    tableToExcel2(api) {
      let a = this.objectToQuery(this.listQuery);
      var b = a.replace("time[0]", "payBeginTime");
      var c = b.replace("time[1]", "payEndTime");
      const elink = document.createElement("a");
      elink.style.display = "none";
      elink.href = config.baseUrl + api + c;
      document.body.appendChild(elink);
      console.log(elink);
      elink.click();
      URL.revokeObjectURL(elink.href); // 释放URL 对象
      document.body.removeChild(elink);
    },
    quickPrint(val) {
      let num = sessionStorage.getItem("printNum") == 2 ? 2 : 1;
      axios
        .post("ReachOrder/prints", {
          orderID: val,
          type: num,
        })
        .then((response) => {
          if (response.data.code === 1) {
            let num2 = num == 1 ? 2 : 1;
            sessionStorage.setItem("printNum", num2);
            this.$message({
              message: response.data.msg,
              type: "success",
              offset: 100,
            });
            this.getList();
          } else {
            this.$message({
              message: response.data.msg,
              type: "warning",
              offset: 100,
            });
          }
        });
    },
    printing(num) {
      this.$confirm("是否需要使用" + num + "号打印机，打印小票?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          axios
            .post("ReachOrder/prints", {
              orderID: this.printerOrder,
              type: num,
            })
            .then((response) => {
              if (response.data.code === 1) {
                this.$message({
                  message: response.data.msg,
                  type: "success",
                  offset: 100,
                });
                this.getList();
              } else {
                this.$message({
                  message: response.data.msg,
                  type: "warning",
                  offset: 100,
                });
              }
            });
        })
        .catch(() => {});
    },
    print(orderID) {
      this.printerVisible = true;
      this.printerOrder = orderID;
    },
    areaChange(arr) {
      this.listQuery.agentID = arr[arr.length - 1];
    },
    getAreaList() {
      let vm = this;
      axios.post("Agents/getAgentArr").then(function (response) {
        let res = response.data;
        if (res.code === 1) {
          vm.tableAreaData = [];
          for (let i = 0; i < res.data.list.length; i++) {
            vm.tableAreaData.push({
              value: res.data.list[i].agentID,
              label: res.data.list[i].agentName,
              children: [],
            });
            for (let j = 0; j < res.data.list[i].children.length; j++) {
              vm.tableAreaData[i].children.push({
                value: res.data.list[i].children[j].agentID,
                label: res.data.list[i].children[j].agentName,
                children: [],
              });
              for (
                let h = 0;
                h < res.data.list[i].children[j].children.length;
                h++
              ) {
                vm.tableAreaData[i].children[j].children.push({
                  value: res.data.list[i].children[j].children[h].agentID,
                  label: res.data.list[i].children[j].children[h].agentName,
                });
              }
            }
          }
        } else {
          vm.$Message.error(res.msg);
        }
      });
    },
    delivery(index, row) {
      let arr = "";
      let target = "";
      if (row) {
        arr = row.orderID;
        target = "ReachOrder/deliver";
      } else {
        if (this.multipleSelection.length > 0) {
          arr = "";
          for (let i in this.multipleSelection) {
            arr += this.multipleSelection[i].orderID + ",";
          }
          arr = arr.slice(0, arr.length - 1);
          target = "ReachOrder/delivers";
        } else {
          this.$message({
            message: "请勾选需要批量操作的数据！",
            type: "warning",
            offset: 100,
          });
          return;
        }
      }
      this.$confirm(row ? "确定发货？" : "确定批量发货？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(() => {
          axios
            .post(target, {
              // masterID: parseInt(sessionStorage.getItem("masterID")),
              orderID: arr,
            })
            .then((response) => {
              if (response.data.code === 1) {
                this.$message({
                  message: response.data.msg,
                  type: "success",
                  offset: 100,
                });

                this.getList();
              } else {
                this.$message({
                  message: response.data.msg,
                  type: "warning",
                  offset: 100,
                });
              }
            });
        })
        .catch(() => {});
    },
    classChange2(arr) {
      this.listQuery.masterID = arr[arr.length - 1];
    },
    /**
     * 完成按钮
     */
    overbtn(index, row) {
      this.$confirm("完成订单后不可撤销，请确认无误后点击确认！", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          axios
            .post("ReachOrder/delivery", { orderID: row.orderID })
            .then((response) => {
              if (response.data.code === 1) {
                this.$message({
                  message: response.data.msg,
                  type: "success",
                  offset: 100,
                });
                this.getList();
              } else {
                this.$message({
                  message: response.data.msg,
                  type: "warning",
                  offset: 100,
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    /**
      发送短信
     */
    sendSMS(orderID) {
      let arr = "";
      let target = "";
      if (orderID) {
        arr = orderID;
        target = "ReachOrder/Sendsms";
      } else {
        if (this.multipleSelection.length > 0) {
          arr = "";
          for (let i in this.multipleSelection) {
            arr += this.multipleSelection[i].orderID + ",";
          }
          arr = arr.slice(0, arr.length - 1);
          target = "ReachOrder/SendSmsList";
        } else {
          this.$message({
            message: "请勾选需要批量操作的数据！",
            type: "warning",
            offset: 100,
          });
          return;
        }
      }
      this.$confirm(
        orderID ? "确认发送提货提醒短信" : "是否 群发 短信？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          axios
            .post(target, {
              // masterID: parseInt(sessionStorage.getItem("masterID")),
              orderID: arr,
            })
            .then((response) => {
              if (response.data.code === 1) {
                this.$message({
                  message: response.data.msg,
                  type: "success",
                  offset: 100,
                });
                this.getList();
              } else {
                this.$message({
                  message: response.data.msg,
                  type: "warning",
                  offset: 100,
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    /**
     * 搜索
     */
    handleSearchList() {
      this.tableShow = {
        currentPage: 1,
        pageSize: 10,
        listCount: 0,
      };
      sessionStorage.setItem("search", JSON.stringify(this.listQuery));
      this.getList(this.multipleSelection);
    },
    handleResetSearch() {
      this.listQuery = {};
      this.multipleSelection = [];
      sessionStorage.removeItem("page");
      sessionStorage.removeItem("size");
      sessionStorage.removeItem("search");
      this.tableShow = {
        currentPage: 1,
        pageSize: 10,
        listCount: 0,
      };
      this.getList(this.multipleSelection);
    },
    /**
     * 表格
     */
    changePage(page) {
      this.tableShow.currentPage = page;
      sessionStorage.setItem("page", this.tableShow.currentPage);
      this.getList(this.multipleSelection);
    },
    changeSize(size) {
      this.tableShow.pageSize = size;
      sessionStorage.setItem("size", this.tableShow.currentPage);
      this.getList(this.multipleSelection);
    },
    handleViewOrder(index, row) {
      this.$router.push({
        name: "order_details",
      });
      sessionStorage.setItem("order_details", row.orderID);
    },
    /**
     * 导出
     */
    handleSelectionChange1(selection, row) {
      let vm = this;
      this.listLoading = true;
      let obj = {
        page: 1,
        size: vm.tableShow.listCount,
        page: vm.tableShow.currentPage,
        size: vm.tableShow.pageSize,
        status: vm.listQuery.status,
        payBeginTime: vm.listQuery.time ? vm.listQuery.time[0] : "",
        payEndTime: vm.listQuery.time ? vm.listQuery.time[1] : "",
        mobile: vm.listQuery.mobile,
        masterID: vm.listQuery.masterID,
      };
      for (let i in obj) {
        obj[i] || delete obj[i];
      }
      axios.get("Order/index", obj).then(function (response) {
        let res = response.data;
        if (res.code === 1) {
          vm.multipleSelection = res.data.list;
          if (selection.length === 0) {
            vm.multipleSelection = [];
          }
          vm.listLoading = false;
        } else {
          if (res.code === -14) {
            vm.$store.commit("logout", vm);
            vm.$router.push({
              name: "login",
            });
          }
        }
      });
    },
    handleSelectionChange(rows, row) {
      let selected = rows.length && rows.indexOf(row) !== -1;
      if (selected) {
        this.multipleSelection.push(row);
      } else if (!selected) {
        for (var i = 0; i < this.multipleSelection.length; i++) {
          if (this.multipleSelection[i].orderID === row.orderID) {
            if (i === 0) {
              this.multipleSelection.shift(); // 删除并返回数组的第一个元素
            } else if (i === this.multipleSelection.length - 1) {
              this.multipleSelection.pop(); // 删除并返回数组的最后一个元素
            } else {
              this.multipleSelection.splice(i, 1); // 删除下标为i的元素
            }
          }
        }
      }
    },
    tableToExcel() {
      let _this = this;
      this.exportData = [];
      const length = _this.multipleSelection.length;
      if (length !== 0) {
        // 列标题，逗号隔开，每一个逗号就是隔开一个单元格
        let abc = JSON.parse(JSON.stringify(_this.multipleSelection));
        let ABC = [];
        for (let j = 0; j < abc.length; j++) {
          ABC.push({
            orderID: abc[j].orderID,
            tradeNo: abc[j].tradeNo,
            amount: abc[j].amount,
            addtypeText: abc[j].addtypeText,
            payTypeText: abc[j].payTypeText,
            StatusText: abc[j].StatusText,
            masterName: abc[j].masterName,
            payTime: abc[j].payTime,
            finishTime: abc[j].finishTime,
          });
        }
        let str =
          "订单ID,订单号,支付金额,订单来源,支付方式,订单状态,自提门店,支付时间,提货时间\n";
        // 增加\t为了不让表格显示科学计数法或者其他格式
        for (let i = 0; i < ABC.length; i++) {
          for (let item in ABC[i]) {
            str += `${ABC[i][item] + "\t"},`;
          }
          str += "\n";
        }
        // encodeURIComponent解决中文乱码;
        let uri =
          "data:text/csv;charset=utf-8,\ufeff" + encodeURIComponent(str);
        // 通过创建a标签实现;
        var link = document.createElement("a");
        link.href = uri;
        // 对下载的文件命名;
        link.download = "预售列表导出.csv";
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        _this.multipleSelection = [];
        _this.$refs.orderTable.clearSelection();
      } else {
        _this.$message({
          message: "不存在数据,请选择数据",
          type: "warning",
          offset: 100,
        });
      }
    },

    hidden() {
      this.deliveryVisible = false;
      this.deliveryData = "";
      setTimeout(function () {
        this.allxx = false;
      }, 1);

      this.logisticsVisible = false;
      this.logisticsTradeNo = {};
      this.getList();
    },
    /**
     * 查询快递
     */
    expressInquiry(index, row) {
      this.logisticsVisible = true;
      this.logisticsTradeNo.orderID = row.orderID;
      this.logisticsTradeNo.tradeNo = row.tradeNo;
    },
    /**
     * 退款
     */
    refund(index, row) {
      this.refundVisible = true;
      this.refundList.orderID = row.orderID;
    },
    RefundSubmit(val) {
      this.refundList.status = val;
      this.$confirm("退款拒绝或确定后无法撤销, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          axios.post("MallOrder/refund", this.refundList).then((response) => {
            if (response.data.code === 1) {
              this.$message({
                message: response.data.msg,
                type: "success",
                offset: 100,
              });
              this.refundVisible = false;
              this.refundList = {};
            } else {
              this.$message({
                message: response.data.msg,
                type: "warning",
                offset: 100,
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    getMasterList() {
      axios
        .post("Master/getMasterList", { page: 1, size: 9999, autotrophy: 1 })
        .then((response) => {
          let res = response.data;
          this.tableMasterData = [];
          if (res.code === 1) {
            for (let i = 0; i < res.data.list.length; i++) {
              this.tableMasterData.push({
                value: res.data.list[i].masterID,
                label: res.data.list[i].trueName,
                // children: []
              });
              // for (let j = 0; j < res.data.list[i].children.length; j++) {
              //   this.tableClassData[i].children.push({
              //     value: res.data.list[i].children[j].classID,
              //     label: res.data.list[i].children[j].className
              //   });
              // }
            }
          } else {
            if (res.code === -14) {
              this.$store.commit("logout", this);
              this.$router.push({
                name: "login",
              });
            } else {
              this.$Message.error(res.msg);
            }
          }
        });
    },
    getList(Selection) {
      let vm = this;
      vm.listLoading = true;
      let obj = {
        page: vm.tableShow.currentPage,
        size: vm.tableShow.pageSize,
        status: vm.listQuery.status,
        payBeginTime: vm.listQuery.time ? vm.listQuery.time[0] : "",
        payEndTime: vm.listQuery.time ? vm.listQuery.time[1] : "",
        mobile: vm.listQuery.mobile,
        masterID: vm.listQuery.masterID,
      };
      for (let i in obj) {
        obj[i] || delete obj[i];
      }
      axios.get("Order/index", { params: obj }).then(function (response) {
        let res = response.data;
        if (res.code === 1) {
          vm.list = res.data.list;
          vm.tableShow.listCount = res.data.count;
          vm.list.map((v, i) => {
            vm.$set(v, "visible", false);
          });
          vm.amount = res.data.sumAmount;
          vm.money = res.data.sumMoney;
          if (Selection) {
            vm.$nextTick(function () {
              for (let i = 0; i < vm.list.length; i++) {
                for (let j = 0; j < Selection.length; j++) {
                  if (vm.list[i].orderID === Selection[j].orderID) {
                    vm.$nextTick(function () {
                      vm.$refs.orderTable.toggleRowSelection(vm.list[i]);
                    });
                  }
                }
              }
            });
          }
        } else {
          if (res.code === -14) {
            vm.$store.commit("logout", vm);
            vm.$router.push({
              name: "login",
            });
          } else {
            vm.$message({
              message: res.msg,
              offset: 100,
              type: "error",
            });
          }
        }
        vm.listLoading = false;
      });
    },
  },
};
</script>
<style scoped>
.input-width {
  width: 203px;
}
.operate-container {
  margin-top: 20px;
}
</style>


